<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--<%@ page import="com.iWen.survey.dao.DAOFactory"%>
<%@ page import="com.iWen.survey.dto.Question" %>
<%@ page import="com.iWen.survey.dao.QuestionDAO" %>
<%@ page import="com.iWen.survey.pager.*" %>--%>

<%--
<jsp:useBean id="pageConfig" class="com.iWen.survey.pager.PageConfig"></jsp:useBean>
--%>
<%--
<jsp:setProperty property="request" name="pageConfig" value="<%=request %>"/>
--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%--<%
	QuestionDAO dao=DAOFactory.getQuestionDAO();
	PageControl pc=new PageControl(dao,pageConfig,"QuestionAdmin.jsp?rand=1");
	pc.setSizePage(5);
	List<Question> sList=pc.getRecord();
 %> --%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>My JSP 'SurveyAudi.jsp' starting page</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/Css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/Css/Admin.css">
    <script language="JavaScript" src="${pageContext.request.contextPath}/Js/jquery.min.js"></script>
    <script language="JavaScript" src="${pageContext.request.contextPath}/Js/Func.js"></script>
    <script language="javascript">window.onload = tableFix;</script>
    <script language="JavaScript" src="${pageContext.request.contextPath}/Js/question/question.js"></script>

</head>
<body>
<div class=nav><a href=admin_main.jsp>桌面</a>»<a href=SurveyAdmin.jsp>问卷列表</a>»题目管理

</div>
<table class=table cellspacing="0" cellpadding="0" align="center">
    <tbody>
    <tr>
        <th width=7%>编号</th>
        <th>题目标题</th>
        <th width=20%>操作 <br></th>
    </tr>

    <c:choose>
        <c:when test="${pageBean.list!=null&&pageBean.list.size()>0}">
            <c:forEach items="${pageBean.list}" var="question">
                <tr>
                    <td>${question.id}</td>

                    <td>${question.head}</td>

                    <td>
                        <a href='javascript:editQuestion(${question.id})'>编辑</a>||
                        <a href='javascript:delQuestion(${question.id})'>删除</a>||
                    <a href='javascript:addQuestion(${sid})'>添加</a>
                    </td>
                </tr>
                </tr>
            </c:forEach>
        </c:when>
        <c:otherwise>
            <td>暂无数据</td>
            <td>暂无数据</td>
            <td><a href='javascript:addQuestion(${sid})' style="color: red;">添加题目</a>
            </td>
        </c:otherwise>
    </c:choose>
    </tbody>
</table>

<!--分页-->
<div class="pull-right">
    <script type="text/javascript">
        function page(pageCode) {
            window.location.href = "${pageContext.request.contextPath}/admin/question/questionManage?pageCode=" + pageCode + "&sid=${sid}";
        }
    </script>
    <jsp:include page="../page.jsp"></jsp:include>
</div>


<script type="text/javascript">
    function delQuestion(qid) {
        if (confirm("确定要删除这个题目吗？") == true) {
            $.post(
                "/admin/question/delete?qid=" + qid,
                function (data) {
                    if (data.code == 200) {
                        alert("修改成功");
                        window.location.href = "${pageContext.request.contextPath}/admin/question/questionManage?sid=" +${sid};
                    } else {
                        alert("修改失败");
                    }
                }, "json")
        }
    }

    function editQuestion(qid) {
        window.location.href = "${pageContext.request.contextPath}/admin/question/search?qid=" + qid;
    }

    function addQuestion(sid) {
        window.location.href = "${pageContext.request.contextPath}/admin/QuestionAdd.jsp?sid=" + sid;
    }

</script>
</body>
</html>
